package com.eschool.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.eschool.mapper.CardMapper;
import com.eschool.mapper.PurchaseMapper;
import com.eschool.pojo.CardDAO;
import com.eschool.pojo.PurchaseDAO;
import com.eschool.service.CardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CardServiceImpl implements CardService {
    @Autowired
    CardMapper CardMapper;
    @Autowired
    PurchaseMapper PurchaseMapper;

    @Override
    public List<PurchaseDAO> stuid2purc(String studentId){
        QueryWrapper queryWrapper1 = new QueryWrapper();
        queryWrapper1.eq("studentId",studentId);
        CardDAO cardDAO = CardMapper.selectOne(queryWrapper1);
        String cardId = cardDAO.getCardId();

        QueryWrapper queryWrapper2 = new QueryWrapper();
        queryWrapper2.eq("cardId",cardId);
        List<PurchaseDAO> purchaseDAOs;
        purchaseDAOs = PurchaseMapper.selectList(queryWrapper2);
        return purchaseDAOs;
    }
}
